#
# The following version number definitions apply to GLib, GModule, GObject,
# GThread and GIO as a whole, so if changes occurred in any of them, they are
# all treated with the same interface and binary age.
#
# Making releases:
#   glib_micro_version += 1;
#   glib_interface_age += 1;
#   glib_binary_age += 1;
# if any functions have been added, set glib_interface_age to 0.
# if backwards compatibility has been broken,
# set glib_binary_age _and_ glib_interface_age to 0.
#
m4_define([glib_major_version], [2])
m4_define([glib_minor_version], [23])
m4_define([glib_micro_version], [3])
m4_define([glib_interface_age], [0])
m4_define([glib_binary_age],
          [m4_eval(100 * glib_minor_version + glib_micro_version)])
m4_define([glib_version],
          [glib_major_version.glib_minor_version.glib_micro_version])

# libtool version related macros
m4_define([glib_lt_release], [glib_major_version.glib_minor_version])
m4_define([glib_lt_current],
          [m4_eval(100 * glib_minor_version + glib_micro_version - glib_interface_age)])
m4_define([glib_lt_revision], [glib_interface_age])
m4_define([glib_lt_age], [m4_eval(glib_binary_age - glib_interface_age)])
m4_define([glib_lt_current_minus_age],
          [m4_eval(glib_lt_current - glib_lt_age)])

# if the minor version number is odd, then we want debugging.  Otherwise
# we only want minimal debugging support.
m4_define([glib_debug_default],
          [m4_if(m4_eval(glib_minor_version % 2), [1], [yes], [minimum])])dnl


AC_INIT([valace], [0.1.0], [sejerpz@tin.it], [valace])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE([dist-bzip2])
AM_MAINTAINER_MODE

AC_PROG_CC
AM_PROG_CC_C_O
AC_DISABLE_STATIC
AC_PROG_LIBTOOL

AH_TEMPLATE([GETTEXT_PACKAGE], [Package name for gettext])
GETTEXT_PACKAGE=valace
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE")
AC_SUBST(GETTEXT_PACKAGE)
AM_GLIB_GNU_GETTEXT
IT_PROG_INTLTOOL([0.35.0])

AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)

GLIB_REQUIRED=2.12.0

PKG_CHECK_MODULES(VALART, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED)
AC_SUBST(VALART_CFLAGS)
AC_SUBST(VALART_LIBS)

GLIB_MAJOR_VERSION=glib_major_version
GLIB_MINOR_VERSION=glib_minor_version
GLIB_MICRO_VERSION=glib_micro_version
GLIB_INTERFACE_AGE=glib_interface_age
GLIB_BINARY_AGE=glib_binary_age
GLIB_VERSION=glib_version

AC_SUBST(GLIB_MAJOR_VERSION)
AC_SUBST(GLIB_MINOR_VERSION)
AC_SUBST(GLIB_MICRO_VERSION)
AC_SUBST(GLIB_VERSION)
AC_SUBST(GLIB_INTERFACE_AGE)
AC_SUBST(GLIB_BINARY_AGE)

AC_DEFINE(GLIB_MAJOR_VERSION, [glib_major_version],
          [Define to the GLIB major version])
AC_DEFINE(GLIB_MINOR_VERSION, [glib_minor_version],
          [Define to the GLIB minor version])
AC_DEFINE(GLIB_MICRO_VERSION, [glib_micro_version],
          [Define to the GLIB micro version])
AC_DEFINE(GLIB_INTERFACE_AGE, [glib_interface_age],
          [Define to the GLIB interface age])
AC_DEFINE(GLIB_BINARY_AGE, [glib_binary_age],
          [Define to the GLIB binary age])


#check for libcharset
# Checks for libcharset
AM_LANGINFO_CODESET
gl_GLIBC21
AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
AC_CHECK_FUNCS(setlocale)




# libtool versioning
LT_RELEASE=glib_lt_release
LT_CURRENT=glib_lt_current
LT_REVISION=glib_lt_revision
LT_AGE=glib_lt_age
LT_CURRENT_MINUS_AGE=glib_lt_current_minus_age
AC_SUBST(LT_RELEASE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)
AC_SUBST(LT_CURRENT_MINUS_AGE)

# define a MAINT-like variable REBUILD which is set if Perl
# and awk are found, so autogenerated sources can be rebuilt
AC_PROG_AWK
AC_CHECK_PROGS(PERL, [perl5 perl])
# We would like indent, but don't require it.
AC_CHECK_PROG(INDENT, indent, indent)
REBUILD=\#
if test "x$enable_rebuilds" = "xyes" && \
     test -n "$PERL" && \
     $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 && \
     test -n "$AWK" ; then
  REBUILD=
fi
AC_SUBST(REBUILD)

dnl ****************************************
dnl *** platform dependent source checks ***
dnl ****************************************

AC_MSG_CHECKING(for platform-dependent source)
case "$host" in
  *-*-cygwin*|*-*-mingw*)
    PLATFORMDEP=gwin32.lo
    ;;
  *)
    PLATFORMDEP=
    ;;
esac
AC_MSG_RESULT($PLATFORMDEP)
AC_SUBST(PLATFORMDEP)


dnl **********************
dnl *** Win32 API libs ***
dnl **********************

case $host in
  *-*-cygwin*)
        G_LIBS_EXTRA="-luser32 -lkernel32"
    ;;
  *-*-mingw*)
        #G_LIBS_EXTRA="-lws2_32 -lole32"
        #G_LIBS_EXTRA="-lmingwm10"
        G_LIBS_EXTRA=""
    ;;
  *)
        G_LIBS_EXTRA=""
    ;;
esac
AC_SUBST(G_LIBS_EXTRA)

# Check if we should compile GRegex
AC_ARG_ENABLE(regex, AC_HELP_STRING([--disable-regex],
              [disable the compilation of GRegex]),
[case "${enableval}" in
  yes) enable_regex=true ;;
  no)  enable_regex=false ;;
  *) AC_MSG_ERROR(bad value ${enableval} for --enable-regex) ;;
esac],
[enable_regex=false])

# defaults


platform_win32=yes
AC_MSG_RESULT($platform_win32)

glib_native_win32=yes
glib_pid_type='void *'
glib_cv_stack_grows=no
cross_compiling=yes
have_threads=win32

AM_CONDITIONAL(OS_WIN32, [test "$glib_native_win32" = "yes"])
AM_CONDITIONAL(OS_WIN32_X64, [test "$LIB_EXE_MACHINE_FLAG" = "X64"])
AM_CONDITIONAL(OS_UNIX, [test "$glib_native_win32" != "yes"])
AM_CONDITIONAL(OS_LINUX, [test "$glib_os_linux" = "yes"])
AM_CONDITIONAL(OS_CARBON, [test "$glib_have_carbon" = "yes"])

AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)
AM_CONDITIONAL(HAVE_THREADS, [test "$have_threads" != "none"])

AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
AM_CONDITIONAL(HAVE_GLIB_RUNTIME_LIBDIR, [test "x$with_runtime_libdir" != "x"])
AM_CONDITIONAL(OS_WIN32_AND_DLL_COMPILATION, [test x$glib_native_win32 = xyes -a x$glib_win32_static_compilation != xyes])

AM_CONDITIONAL(MS_LIB_AVAILABLE, [test x$ms_librarian = xyes])
g_have_gnuc_visibility=yes
AM_CONDITIONAL(HAVE_GNUC_VISIBILITY, [test x$g_have_gnuc_visibility = xyes])

AM_CONDITIONAL(ENABLE_REGEX, $enable_regex)

dnl ******************************************************************
dnl *** Look for glib-genmarshal in PATH if we are cross-compiling ***
dnl ******************************************************************

AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)

if test $cross_compiling = yes; then
  AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal, no)
  if test x$GLIB_GENMARSHAL = xno; then
    AC_MSG_ERROR(Could not find a glib-genmarshal in your PATH)
  fi
fi

AC_CONFIG_FILES([Makefile
	glib/Makefile
	glib/libcharset/Makefile
	gobject/Makefile
	gthread/Makefile
	po/Makefile.in])

AC_OUTPUT
